//
//  ChangeCheckerAppDelegate.h
//  iChangeChecker
//
//  Created by Lauri Koskela on 16.4.2011.
//  Copyright 2011 Lauri Koskela. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import <OAuthConsumer/OAuthConsumer.h>

@class SiteArrayController;
@class UpdateOperation;
@class PageTableView;

@interface ChangeCheckerAppDelegate : NSObject <NSApplicationDelegate, NSToolbarDelegate> {
@private
    NSPersistentStoreCoordinator *__persistentStoreCoordinator;
    NSManagedObjectModel *__managedObjectModel;
    NSManagedObjectContext *__managedObjectContext;
 
    NSStatusItem *statusItem;
    NSMenuItem *separator;
    NSMenuItem *updatedLabel;
    
    UpdateOperation *updateOperation;
    NSOperationQueue *updateQueue;
    
    NSTimer *updateTimer;
    
    NSString *selectedPrefTab;
    
    OAToken *accessToken;
}
@property (weak) IBOutlet NSToolbar *toolbar;
@property (weak) IBOutlet NSView *preferencesPagesView;
@property (weak) IBOutlet NSView *preferencesGeneralView;
@property (weak) IBOutlet NSView *mainView;
@property (weak) IBOutlet NSToolbarItem *generalItem;
@property (weak) IBOutlet NSToolbarItem *pagesItem;

@property (weak) IBOutlet NSWindow *window;
@property (weak) IBOutlet NSPopUpButton *updateIntervalPopUp;
@property (unsafe_unretained) IBOutlet PageTableView *siteTableView;
@property (weak) IBOutlet NSButton *loginStartCheckBox;
@property (weak) IBOutlet NSMenu *statusMenu;
@property (weak) IBOutlet SiteArrayController *siteArrayController;

@property (weak) IBOutlet NSTextField *titleField;
@property (weak) IBOutlet NSTextField *addressField;

@property (nonatomic, strong) NSStatusItem *statusItem; // The menu bar status item
@property (nonatomic, strong) NSMenuItem *separator;
@property (nonatomic, strong) NSMenuItem *updatedLabel;
@property (weak) IBOutlet NSMenuItem *lastUpdatedItem;
@property (nonatomic, strong) NSTimer *updateTimer;

@property (weak) IBOutlet NSTextField *twitterPINField;
@property (weak) IBOutlet NSButton *twitterCheckPINButton;
@property (weak) IBOutlet NSTextField *twitterTargetField;
@property (weak) IBOutlet NSProgressIndicator *requestIndicator;
@property (weak) IBOutlet NSButton *requestButton;
@property (weak) IBOutlet NSProgressIndicator *checkPINIndicator;
@property (weak) IBOutlet NSImageView *twitterStatusSuccessIcon;
@property (weak) IBOutlet NSImageView *twitterStatusFailIcon;

@property (nonatomic, strong, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (nonatomic, strong, readonly) NSManagedObjectModel *managedObjectModel;
@property (nonatomic, strong, readonly) NSManagedObjectContext *managedObjectContext;


- (IBAction)saveAction:sender;
- (IBAction)updateAll:(id)sender;
- (IBAction)openPage:(id)sender;

- (IBAction)getRequestToken:(id)sender;
- (IBAction)getAccessToken:(id)sender;

- (IBAction)showPreferences:(id)sender;
- (IBAction)chooseGeneralTab:(id)sender;
- (IBAction)choosePagesTab:(id)sender;
- (void)updateTimerFired:(NSTimer*)timer;

- (void)sendTwitterNotificationWithName:(NSString*)name link:(NSString*)link;
@end
